export default {
    name: 'Abnormallist',
    components: {

    },
    data() {
        return {
            currentPage: 1,
            pagesize: 5,
            total: 0,
            height: '600',
            multipleSelection: [],
            searchForm: {
                deviceId: '',
                deviceName: '',
                deviceType: ''
            },
            TypeData: [],
            previewlistabnData: []
        }
    },
    computed: {
        offset:function(){
            return (this.currentPage -1)*this.pagesize;
        }
    },
    watch: {

    },
    created() {
      this.selectType();
      this.initAbnomalDeviceList();
    },
    mounted() {

    },
    methods: {
        //获取设备类别
         selectType(){
            this.$http.get("/deviceTypeController/queryAllDeviceType")
             .then((res) => {
               if(res.status == 200){
                   this.TypeData = res.data;
                }
             }).catch((err) => {
                 console.log(err);
           })
         },
        initAbnomalDeviceList(){
            var listParamsObj ={
                limit:this.pagesize,
                offset:this.offset,
                abnormalDevice:0,
                deviceName:this.searchForm.deviceName,
                deviceId: this.searchForm.deviceId,
                deviceModelName : this.searchForm.deviceType,
            }
           this.$http.post('/deviceCommonInfoController/devicesPage',this.qs.stringify(listParamsObj))
            .then((res) => {
              if(res.status == 200){
                  if(res.data != null && res.total != null){
                    this.previewlistabnData = res.data;
                    this.total = res.total;
                  } else if(res.data == null && res.total == null){
                    this.$message.error(res.msg);
                    this.previewlistabnData = [];
                    this.total = 0;
                 }
              } 
            }).catch((err) => {
             console.log(err);
          });
        },
        searchabnomalDevice(){
          this.currentPage = 1;
          this.initAbnomalDeviceList();
        },
        toggleSelection(rows) {
            if (rows) {
                rows.forEach(row => {
                    this.$refs.multipleSelection.toggleRowSelection(row);
                });
            } else {
                this.$refs.multipleTable.clearSelection();
          }
        },
        handleSelectionChange() {
            this.multipleSelection = [];
        },
        handleSizeChange(val) {
            this.pagesize = val;
            this.initAbnomalDeviceList();
        },
        handleCurrentChange(val) {
            this.currentPage = val;
            this.initAbnomalDeviceList();
        }
    },
}